package org.liurq.rabbitmq.controller;

import org.liurq.rabbitmq.config.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RabbitMQController {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @RequestMapping(value = "/sendOrder")
    public String generateOrder(String order,String routeKey) {
        System.out.println("生产者信息：" + order.toString());
        rabbitTemplate.convertAndSend(Constants.ORDER_EXCHANGE, routeKey ,order);
        return "成功";
    }
}
